package com.xxx.gaoxi.common.service.facade.entity.dto;

import com.xxx.gaoxi.common.service.facade.entity.AbstractModel;
import org.springframework.http.HttpStatus;

/**
 * Description
 * ...
 * DATE 2018/4/2.
 *
 * @author Mr. Chun.
 */
public class RetDTO<T> extends AbstractModel {
    private int code;
    private String info;
    private T data;

    public RetDTO(int code, String info) {
        this.code = code;
        this.info = info;
    }

    public RetDTO(int code, String info, T data) {
        this.code = code;
        this.info = info;
        this.data = data;
    }

    public static <E> RetDTO<E> getSuccess(E data) {
        return new RetDTO<E>(HttpStatus.OK.value(), "success", data);
    }

    public static <E> RetDTO<E> getError(int code) {
        return new RetDTO<E>(code, "error", null);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
